import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/home/HomeView.vue'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        name: 'home1',
        component: HomeView
    },
    {
        path: '/about',
        name: 'about',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
            import ( /* webpackChunkName: "about" */ '../views/about/AboutView.vue')
    }
]

const router = new VueRouter({
    routes
});
//beforeEach 路由守卫 访问页面之前执行的逻辑
//to 要跳转的页面
//from 跳转之前的页面
//next()放行
router.beforeEach((to, from, next) => {
    console.log("-------to--------", to);
    console.log("-------from--------", from);
    next()
})

export default router